﻿USE [master]
GO
CREATE DATABASE [xRepair]
GO
ALTER DATABASE [xRepair] MODIFY FILE
( NAME = N'xRepair' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
GO
ALTER DATABASE [xRepair] MODIFY FILE
( NAME = N'xRepair_log', SIZE = 1024KB , MAXSIZE = 51200KB , FILEGROWTH = 10240KB )
GO
ALTER DATABASE [xRepair] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [xRepair].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [xRepair] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [xRepair] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [xRepair] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [xRepair] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [xRepair] SET ARITHABORT OFF 
GO
ALTER DATABASE [xRepair] SET AUTO_CLOSE ON 
GO
ALTER DATABASE [xRepair] SET AUTO_CREATE_STATISTICS ON 
GO
ALTER DATABASE [xRepair] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [xRepair] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [xRepair] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [xRepair] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [xRepair] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [xRepair] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [xRepair] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [xRepair] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [xRepair] SET  ENABLE_BROKER 
GO
ALTER DATABASE [xRepair] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [xRepair] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [xRepair] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [xRepair] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [xRepair] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [xRepair] SET READ_COMMITTED_SNAPSHOT OFF 
GO
ALTER DATABASE [xRepair] SET HONOR_BROKER_PRIORITY OFF 
GO
ALTER DATABASE [xRepair] SET RECOVERY SIMPLE 
GO
ALTER DATABASE [xRepair] SET  MULTI_USER 
GO
ALTER DATABASE [xRepair] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [xRepair] SET DB_CHAINING OFF 
GO
EXEC sys.sp_db_vardecimal_storage_format N'xRepair', N'ON'
GO
USE [xRepair]
GO
/****** Object:  StoredProcedure [dbo].[AddNewBrand]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[AddNewBrand]
		 @GenericTypesID	    INT
		,@BrandName				NVARCHAR(200)
		,@CreatedAt				DATETIME = NULL
		,@CreatedBy				NVARCHAR(50) = NULL
		,@LastUpdatedAt			DATETIME = NULL
		,@LastUpdatedBy			NVARCHAR(50) = NULL
		,@NewIdentity			INT = NULL OUTPUT
AS
BEGIN

	SET NOCOUNT ON;
	
	INSERT INTO [dbo].[Brand]
           ([GenericTypesID]
		   ,[BrandName]
		   ,[IsActive]
           ,[CreatedAt]
           ,[CreatedBy]
           ,[LastUpdatedAt]
           ,[LastUpdatedBy]
           )
     VALUES
           (@GenericTypesID
           ,@BrandName
           ,1
           ,@CreatedAt
           ,@CreatedBy
           ,@LastUpdatedAt
		   ,@LastUpdatedBy
		   )

	SELECT @NewIdentity = @@IDENTITY

END



GO
/****** Object:  StoredProcedure [dbo].[AddNewGenericTypes]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[AddNewGenericTypes]
		@Description			NVARCHAR(1000)
		,@CreatedAt				datetime
		,@CreatedBy				NVARCHAR(50)
		,@LastUpdatedAt			datetime
		,@LastUpdatedBy			NVARCHAR(50)
		,@NewIdentity			INT = NULL OUTPUT
AS
BEGIN

	SET NOCOUNT ON;
	
	INSERT INTO [dbo].[GenericTypes]
           ([Description]
		   ,[IsActive]
           ,[CreatedAt]
           ,[CreatedBy]
           ,[LastUpdatedAt]
           ,[LastUpdatedBy]
           )
     VALUES
           (@Description
           ,1
           ,@CreatedAt
           ,@CreatedBy
           ,@LastUpdatedAt
		   ,@LastUpdatedBy
		   )

	SELECT @NewIdentity = @@IDENTITY

END



GO
/****** Object:  StoredProcedure [dbo].[AddNewModel]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[AddNewModel]
		 @BrandID				INT
		,@ModelName				NVARCHAR(200)
		,@Version				NVARCHAR(50)
		,@Manufacturer			NVARCHAR(500)
		,@CreatedAt				DATETIME = NULL
		,@CreatedBy				NVARCHAR(50) = NULL		
		,@NewIdentity			INT = NULL OUTPUT
AS
BEGIN

	SET NOCOUNT ON;
	
	INSERT INTO [dbo].[Model]
           ([BrandID]
		   ,[ModelName]
           ,[Version]
           ,[Manufacturer]
           ,[IsActive]
           ,[CreatedAt]
           ,[CreatedBy])
     VALUES
           (@BrandID
		   ,@ModelName
           ,@Version
           ,@Manufacturer
           ,1
           ,@CreatedAt
           ,@CreatedBy)

	SELECT @NewIdentity = @@IDENTITY

END



GO
/****** Object:  StoredProcedure [dbo].[AddNewOrder]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[AddNewOrder]
		 @CustomerID				INT
		 ,@CreatedAt				DATETIME = NULL
		 ,@CreatedBy				NVARCHAR(50)
		 ,@CustomerDescription		NVARCHAR(MAX)
	   	 ,@ServiceID				INT
		 ,@TechnicianID				INT
		 ,@AcceptedAt				DATETIME = NULL
		 ,@TechnicianDescription	NVARCHAR(MAX)
		 ,@DueDate					DATETIME = NULL	
		 ,@LastUpdatedAt			DATETIME = NULL
		 ,@LastUpdatedBy			NVARCHAR(50)
		 ,@StatusID					INT
		 ,@ExtraFee					FLOAT
		 ,@ExtraFeeNote				NVARCHAR(2000)
		 ,@BillingAddress			NVARCHAR(MAX)
		 ,@ShippingAddress			NVARCHAR(MAX)
		 ,@NewIdentity				INT = NULL OUTPUT
AS
BEGIN

	SET NOCOUNT ON;
	
	INSERT INTO [dbo].[Orders]
           ([CustomerID]
		   ,[CreatedAt]
		   ,[CreatedBy]
		   ,[CustomerDescription]
	   	   ,[ServiceID]
		   ,[TechnicianID]
		   ,[AcceptedAt]
		   ,[TechnicianDescription]
		   ,[DueDate]
		   ,[LastUpdatedAt]
		   ,[LastUpdatedBy]
		   ,[StatusID]
		   ,[ExtraFee]
		   ,[ExtraFeeNote]
		   ,[BillingAddress]
		   ,[ShippingAddress]
           )
     VALUES
           ( @CustomerID				
			 ,@CreatedAt
			 ,@CreatedBy				
			 ,@CustomerDescription		
	   		 ,@ServiceID				
			 ,@TechnicianID				
			 ,@AcceptedAt				
			 ,@TechnicianDescription	
			 ,@DueDate					
			 ,@LastUpdatedAt			
			 ,@LastUpdatedBy			
			 ,@StatusID					
			 ,@ExtraFee					
			 ,@ExtraFeeNote				
			 ,@BillingAddress			
			 ,@ShippingAddress		
		   )

	SELECT @NewIdentity = @@IDENTITY

END


GO
/****** Object:  StoredProcedure [dbo].[AddNewOrders]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[AddNewOrders]
		 @CustomerID				INT
		 ,@CreatedAt				DATETIME
		 ,@CustomerDescription		NVARCHAR(MAX)
	   	 ,@ServiceID				INT
		 ,@TechnicianID				INT
		 ,@AcceptedAt				DATETIME
		 ,@TechnicianDescription	NVARCHAR(MAX)
		 ,@DueDate					DATETIME
		 ,@LastUpdatedAt			DATETIME
		 ,@LastUpdatedBy			INT
		 ,@StatusID					INT
		 ,@ExtraFee					FLOAT
		 ,@ExtraFeeNote				NVARCHAR(2000)
		 ,@BillingAddress			NVARCHAR(MAX)
		 ,@ShippingAddress			NVARCHAR(MAX)
		 ,@NewIdentity				INT = NULL OUTPUT
AS
BEGIN

	SET NOCOUNT ON;
	
	INSERT INTO [dbo].[Orders]
           ([CustomerID]
		   ,[CreatedAt]
		   ,[CustomerDescription]
	   	   ,[ServiceID]
		   ,[TechnicianID]
		   ,[AcceptedAt]
		   ,[TechnicianDescription]
		   ,[DueDate]
		   ,[LastUpdatedAt]
		   ,[LastUpdatedBy]
		   ,[StatusID]
		   ,[ExtraFee]
		   ,[ExtraFeeNote]
		   ,[BillingAddress]
		   ,[ShippingAddress]
           )
     VALUES
           ( @CustomerID				
			 ,@CreatedAt				
			 ,@CustomerDescription		
	   		 ,@ServiceID				
			 ,@TechnicianID				
			 ,@AcceptedAt				
			 ,@TechnicianDescription	
			 ,@DueDate					
			 ,@LastUpdatedAt			
			 ,@LastUpdatedBy			
			 ,@StatusID					
			 ,@ExtraFee					
			 ,@ExtraFeeNote				
			 ,@BillingAddress			
			 ,@ShippingAddress		
		   )

	SELECT @NewIdentity = @@IDENTITY

END



GO
/****** Object:  StoredProcedure [dbo].[AddNewService]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[AddNewService]
		 @GenericTypesID		INT
		,@SymptomTypeID			INT
		,@ServiceName			NVARCHAR(500)
		,@ServiceDescription	NVARCHAR(MAX)
		,@LaborCost				FLOAT
		,@DiscountLabor			FLOAT
		,@PartCost				FLOAT
		,@DiscountPart			FLOAT		
		,@NewIdentity			INT = NULL OUTPUT
AS
BEGIN

	SET NOCOUNT ON;
	
	INSERT INTO [dbo].[Services]
           ([GenericTypesID]
		   ,[SymptomTypeID]
           ,[ServiceName]
           ,[ServiceDescription]
           ,[LaborCost]
           ,[DiscountLabor]
           ,[PartCost]
           ,[DiscountPart]
           ,[IsActive])
     VALUES
           (@GenericTypesID
		   ,@SymptomTypeID
           ,@ServiceName
           ,@ServiceDescription
           ,@LaborCost
           ,@DiscountLabor
           ,@PartCost
           ,@DiscountPart
           ,1)

	SELECT @NewIdentity = @@IDENTITY

END



GO
/****** Object:  StoredProcedure [dbo].[AddNewSymptom]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[AddNewSymptom]
	 @ModelID			INT,
	 @BrandID			INT,	 
	 @Name				NVARCHAR(200)
    ,@Description		NVARCHAR(MAX)
	,@NewIdentity		INT = NULL OUTPUT
AS
BEGIN

	SET NOCOUNT ON;

    INSERT INTO [dbo].[SymptomTypes]
           ([ModelID]
		   ,[BrandID]
		   ,[Name]
           ,[Description]
           ,[IsActive])
     VALUES
           (@ModelID
		   ,@BrandID
		   ,@Name
           ,@Description
           ,1)

	SELECT @NewIdentity = @@IDENTITY
END





GO
/****** Object:  StoredProcedure [dbo].[AddNewUser]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[AddNewUser]
	@RoleID					INT
	,@Username				NVARCHAR(50)
	,@Password				NVARCHAR(200)
	,@Salt					VARCHAR(64)
	,@Alias					NVARCHAR(200)
	,@CreatedAt				DATETIME
	,@CreatedBy				NVARCHAR(50)
	,@LastUpdatedAt			DATETIME
	,@LastUpdatedBy			NVARCHAR(50)
	,@NewIdentity			INT = NULL OUTPUT
AS
BEGIN
	SET NOCOUNT ON;
INSERT INTO [dbo].[Users]
           ([RoleID]
           ,[Username]
           ,[Password]
           ,[Salt]
           ,[Alias]
           ,[CreatedAt]
           ,[CreatedBy]
           ,[LastUpdatedAt]
           ,[LastUpdatedBy])
     VALUES
           (@RoleID
		   ,@Username
		   ,@Password
		   ,@Salt
		   ,@Alias
		   ,@CreatedAt
		   ,@CreatedBy
		   ,@LastUpdatedAt
		   ,@LastUpdatedBy
		   )

	SELECT @NewIdentity = @@IDENTITY

END




GO
/****** Object:  StoredProcedure [dbo].[DeactivateBrandByID]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[DeactivateBrandByID]
	@ID					INT,
	@Rowcount			INT = -1 OUTPUT
AS
BEGIN

	SET NOCOUNT ON;

    UPDATE [dbo].[Brand]
	SET [IsActive] = 0
	WHERE [ID] = @ID

	SELECT @Rowcount = @@ROWCOUNT
END



GO
/****** Object:  StoredProcedure [dbo].[DeactivateOrderByID]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[DeactivateOrderByID]
	@ID					INT,
	@Rowcount			INT = -1 OUTPUT
AS
BEGIN

	SET NOCOUNT ON;

    UPDATE [dbo].[Orders]
	SET [IsActive] = 0
	WHERE [ID] = @ID

	SELECT @Rowcount = @@ROWCOUNT
END


GO
/****** Object:  StoredProcedure [dbo].[DeactiveGenericTypesByID]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[DeactiveGenericTypesByID]
	@ID					INT,
	@Rowcount			INT = -1 OUTPUT
AS
BEGIN

	SET NOCOUNT ON;

    UPDATE [dbo].[GenericTypes]
	SET [IsActive] = 0
	WHERE [ID] = @ID

	SELECT @Rowcount = @@ROWCOUNT
END



GO
/****** Object:  StoredProcedure [dbo].[DeactiveModelByID]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[DeactiveModelByID]
	@ID					INT,
	@Rowcount			INT = -1 OUTPUT
AS
BEGIN

	SET NOCOUNT ON;

    UPDATE [dbo].[Model]
	SET [IsActive] = 0
	WHERE [ID] = @ID

	SELECT @Rowcount = @@ROWCOUNT
END



GO
/****** Object:  StoredProcedure [dbo].[DeactiveServiceByID]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[DeactiveServiceByID]
	@ID					INT,
	@Rowcount			INT = -1 OUTPUT
AS
BEGIN

	SET NOCOUNT ON;

	UPDATE [dbo].[Services]
	SET [IsActive] = 0
	WHERE [ID] = @ID

	SELECT @Rowcount = @@ROWCOUNT
END



GO
/****** Object:  StoredProcedure [dbo].[DeactiveSymptomByID]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[DeactiveSymptomByID]
	@ID					INT,
	@Rowcount			INT = -1 OUTPUT
AS
BEGIN

	SET NOCOUNT ON;

    UPDATE [dbo].[SymptomTypes]
	SET [IsActive] = 0
	WHERE [ID] = @ID

	SELECT @Rowcount = @@ROWCOUNT
END



GO
/****** Object:  StoredProcedure [dbo].[GetAllActiveBrand]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[GetAllActiveBrand]	
AS
BEGIN

	SET NOCOUNT ON;

	SELECT [ID]
		,[GenericTypesID]
		,[BrandName]
		,[CreatedAt]
		,[CreatedBy]
		,[LastUpdatedAt]
		,[LastUpdatedBy]
	FROM [xRepair].[dbo].[Brand] WITH(NOLOCK)
	WHERE [IsActive] = 1 OR [IsActive] IS NULL

END



GO
/****** Object:  StoredProcedure [dbo].[GetAllActiveBrands]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[GetAllActiveBrands]	
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT
		 [ID]
		,[GenericTypesID]
		,[BrandName]
		,[IsActive]
		,[CreatedAt]
		,[CreatedBy]
		,[LastUpdatedAt]
		,[LastUpdatedBy]
	FROM [xRepair].[dbo].[Brand] WITH(NOLOCK)
	WHERE ([IsActive] IS NULL OR [IsActive] = 1)

END

GO
/****** Object:  StoredProcedure [dbo].[GetAllActiveGenericTypes]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[GetAllActiveGenericTypes]	
AS
BEGIN

	SET NOCOUNT ON;

	SELECT [ID]
		,[Description]
		,[CreatedAt]
		,[CreatedBy]
		,[LastUpdatedAt]
		,[LastUpdatedBy]
	FROM [xRepair].[dbo].[GenericTypes] WITH(NOLOCK)
	WHERE [IsActive] = 1 OR [IsActive] IS NULL

END



GO
/****** Object:  StoredProcedure [dbo].[GetAllActiveModel]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[GetAllActiveModel]	
AS
BEGIN

	SET NOCOUNT ON;

	SELECT [ID]
		,[BrandID]
		,[ModelName]
		,[Version]
		,[Manufacturer]
		,[CreatedAt]
		,[CreatedBy]
		,[LastUpdatedAt]
		,[LastUpdatedBy]
	FROM [xRepair].[dbo].[Model] WITH(NOLOCK)
	WHERE [IsActive] = 1 OR [IsActive] IS NULL

END



GO
/****** Object:  StoredProcedure [dbo].[GetAllActiveModelByBrandID]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[GetAllActiveModelByBrandID]
		@BrandID				INT	
AS
BEGIN

	SET NOCOUNT ON;

	SELECT [ID]
		,[BrandID]
		,[ModelName]
		,[Version]
		,[Manufacturer]
		,[CreatedAt]
		,[CreatedBy]
		,[LastUpdatedAt]
		,[LastUpdatedBy]
	FROM [xRepair].[dbo].[Model] WITH(NOLOCK)
	WHERE 
	([IsActive] = 1	AND	[BrandID] = @BrandID)
	OR ([IsActive] IS NULL	AND	  [BrandID] = @BrandID)
END



GO
/****** Object:  StoredProcedure [dbo].[GetAllActiveOrders]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[GetAllActiveOrders]	
AS
BEGIN

	SET NOCOUNT ON;

	SELECT [ID]
      ,[CustomerID]
      ,[CreatedAt]
      ,[CustomerDescription]
      ,[ServiceID]
      ,[TechnicianID]
      ,[AcceptedAt]
      ,[TechnicianDescription]
      ,[DueDate]
      ,[LastUpdatedAt]
      ,[LastUpdatedBy]
      ,[StatusID]
      ,[ExtraFee]
      ,[ExtraFeeNote]
      ,[BillingAddress]
      ,[ShippingAddress]
      ,[CreatedBy]
	FROM [xRepair].[dbo].Orders WITH(NOLOCK)
	WHERE [IsActive] = 1 OR [IsActive] IS NULL

END


GO
/****** Object:  StoredProcedure [dbo].[GetAllActiveServices]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[GetAllActiveServices]	
AS
BEGIN

	SET NOCOUNT ON;

	SELECT 
		[ID]		
		,[GenericTypesID]
		,[SymptomTypeID]
		,[ServiceName]
		,[ServiceDescription]
		,[LaborCost]
		,[DiscountLabor]
		,[PartCost]
		,[DiscountPart]
	FROM [xRepair].[dbo].[Services] WITH(NOLOCK)
	WHERE [IsActive] = 1 OR [IsActive] IS NULL

END



GO
/****** Object:  StoredProcedure [dbo].[GetAllActiveSymptoms]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[GetAllActiveSymptoms]
AS
BEGIN
	
	SET NOCOUNT ON;

	SELECT 
		 [ID]
		,[ModelID]
		,[BrandID]
		,[Name]
		,[Description]
		,[CreatedAt]
		,[CreatedBy]
		,[LastUpdatedAt]
		,[LastUpdatedBy]
	FROM [xRepair].[dbo].[SymptomTypes] WITH(NOLOCK)
	WHERE [IsActive] = 1 OR [IsActive] IS NULL
END





GO
/****** Object:  StoredProcedure [dbo].[GetUserInfoByCredentials]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[GetUserInfoByCredentials]
	@Username		NVARCHAR(50),
	@Password		NVARCHAR(200)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT 
		 [ID]
		,[RoleID]
		,[Username]
		,[Password]
		,[Salt]
		,[Alias]
	FROM [xRepair].[dbo].[Users] WITH(NOLOCK)
	WHERE 
		([IsActive] = 1 OR [IsActive] IS NULL)
		AND [Username] = @Username
		AND [Password] = @Password

END

GO
/****** Object:  StoredProcedure [dbo].[UpdateBrand]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[UpdateBrand]
		 @ID					INT
		,@GenericTypesID		INT	
		,@BrandName				NVARCHAR(200)		
		,@LastUpdatedAt			DATETIME = NULL
		,@LastUpdatedBy			NVARCHAR(50) = NULL
		,@Rowcount				INT = -1 OUTPUT
AS
BEGIN

	SET NOCOUNT ON;

	UPDATE [dbo].[Brand]
	SET [GenericTypesID] =	@GenericTypesID
		,[BrandName]	 =	@BrandName		
		,[LastUpdatedAt] =	@LastUpdatedAt
		,[LastUpdatedBy] =	@LastUpdatedBy
	WHERE [ID] = @ID

    SELECT @Rowcount = @@ROWCOUNT
END



GO
/****** Object:  StoredProcedure [dbo].[UpdateGenericTypes]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[UpdateGenericTypes]
		@ID						INT
		,@Description			NVARCHAR(1000)	
		,@IsActive				BIT
		,@CreatedAt				DATETIME	
		,@CreatedBy				NVARCHAR(50)
		,@LastUpdatedAt			DATETIME
		,@LastUpdatedBy			NVARCHAR(50)
		,@Rowcount				INT = -1 OUTPUT
AS
BEGIN

	SET NOCOUNT ON;

	UPDATE [dbo].[GenericTypes]
	SET [Description]	 =	@Description
		,[IsActive]		 =	@IsActive
		,[CreatedAt]	 =	@CreatedAt
		,[CreatedBy]	 =	@CreatedBy
		,[LastUpdatedAt] =	@LastUpdatedAt
		,[LastUpdatedBy] =	@LastUpdatedBy
	WHERE [ID] = @ID

    SELECT @Rowcount = @@ROWCOUNT
END



GO
/****** Object:  StoredProcedure [dbo].[UpdateModel]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[UpdateModel]
		@ID						INT
		,@BrandID				INT	
		,@ModelName				NVARCHAR(200)	
		,@Version				NVARCHAR(50)
		,@Manufacturer			NVARCHAR(500)
		,@LastUpdatedAt			DATETIME = NULL
		,@LastUpdatedBy			NVARCHAR(50) = NULL
		,@Rowcount				INT = -1 OUTPUT
AS
BEGIN

	SET NOCOUNT ON;

	UPDATE [dbo].[Model]
	SET [BrandID]		 =	@BrandID
		,[ModelName]	 =	@ModelName
		,[Version]		 =	@Version
		,[Manufacturer]	 =	@Manufacturer		
		,[LastUpdatedAt] =	@LastUpdatedAt
		,[LastUpdatedBy] =	@LastUpdatedBy
	WHERE [ID] = @ID

    SELECT @Rowcount = @@ROWCOUNT
END



GO
/****** Object:  StoredProcedure [dbo].[UpdateOrder]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[UpdateOrder]
		  @ID						INT
		 ,@CustomerID				INT
		 ,@CustomerDescription		NVARCHAR(MAX)
	   	 ,@ServiceID				INT
		 ,@TechnicianID				INT
		 ,@AcceptedAt				DATETIME = NULL
		 ,@TechnicianDescription	NVARCHAR(MAX)
		 ,@DueDate					DATETIME = NULL
		 ,@LastUpdatedAt			DATETIME = NULL
		 ,@LastUpdatedBy			NVARCHAR(50) = NULL
		 ,@StatusID					INT
		 ,@ExtraFee					FLOAT
		 ,@ExtraFeeNote				NVARCHAR(2000)
		 ,@BillingAddress			NVARCHAR(MAX)
		 ,@ShippingAddress			NVARCHAR(MAX)
		 ,@Rowcount					INT = -1 OUTPUT
AS
BEGIN

	SET NOCOUNT ON;
	
	UPDATE [dbo].[Orders]			
	SET		[CustomerID]			= @CustomerID		
		   ,[CustomerDescription]	= @CustomerDescription
	   	   ,[ServiceID]				= @ServiceID
		   ,[TechnicianID]			= @TechnicianID
		   ,[AcceptedAt]			= @AcceptedAt
		   ,[TechnicianDescription]	= @TechnicianDescription
		   ,[DueDate]				= @DueDate
		   ,[LastUpdatedAt]			= @LastUpdatedAt
		   ,[LastUpdatedBy]			= @LastUpdatedBy
		   ,[StatusID]				= @StatusID
		   ,[ExtraFee]				= @ExtraFee
		   ,[ExtraFeeNote]			= @ExtraFeeNote
		   ,[BillingAddress]		= @BillingAddress
		   ,[ShippingAddress]		= @ShippingAddress	
	WHERE [ID] = @ID

	SELECT @Rowcount = @@ROWCOUNT
END


GO
/****** Object:  StoredProcedure [dbo].[UpdateOrders]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[UpdateOrders]
		  @ID						INT
		 ,@CustomerID				INT
		 ,@CreatedAt				DATETIME
		 ,@CustomerDescription		NVARCHAR(MAX)
	   	 ,@ServiceID				INT
		 ,@TechnicianID				INT
		 ,@AcceptedAt				DATETIME
		 ,@TechnicianDescription	NVARCHAR(MAX)
		 ,@DueDate					DATETIME
		 ,@LastUpdatedAt			DATETIME
		 ,@LastUpdatedBy			INT
		 ,@StatusID					INT
		 ,@ExtraFee					FLOAT
		 ,@ExtraFeeNote				NVARCHAR(2000)
		 ,@BillingAddress			NVARCHAR(MAX)
		 ,@ShippingAddress			NVARCHAR(MAX)
		 ,@Rowcount					INT = -1 OUTPUT
AS
BEGIN

	SET NOCOUNT ON;
	
	UPDATE [dbo].[Orders]			
	SET		[CustomerID]			= @CustomerID		
		   ,[CreatedAt]				= @CreatedAt
		   ,[CustomerDescription]	= @CustomerDescription
	   	   ,[ServiceID]				= @ServiceID
		   ,[TechnicianID]			= @TechnicianID
		   ,[AcceptedAt]			= @AcceptedAt
		   ,[TechnicianDescription]	= @TechnicianDescription
		   ,[DueDate]				= @DueDate
		   ,[LastUpdatedAt]			= @LastUpdatedAt
		   ,[LastUpdatedBy]			= @LastUpdatedBy
		   ,[StatusID]				= @StatusID
		   ,[ExtraFee]				= @ExtraFee
		   ,[ExtraFeeNote]			= @ExtraFeeNote
		   ,[BillingAddress]		= @BillingAddress
		   ,[ShippingAddress]		= @ShippingAddress	
	WHERE [ID] = @ID

	SELECT @Rowcount = @@ROWCOUNT
END



GO
/****** Object:  StoredProcedure [dbo].[UpdateService]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[UpdateService]
		@ID						INT	
		,@GenericTypesID		INT	
		,@SymptomTypeID			INT
		,@ServiceName			NVARCHAR(500)
		,@ServiceDescription	NVARCHAR(MAX)
		,@LaborCost				FLOAT
		,@DiscountLabor			FLOAT
		,@PartCost				FLOAT
		,@DiscountPart			FLOAT	
		,@IsActive				BIT	
		,@Rowcount				INT = -1 OUTPUT
AS
BEGIN

	SET NOCOUNT ON;

	UPDATE [dbo].[Services]
	SET [GenericTypesID]		= @GenericTypesID
		,[SymptomTypeID]		= @SymptomTypeID
		,[ServiceName]			= @ServiceName
		,[ServiceDescription]	= @ServiceDescription
		,[LaborCost]			= @LaborCost
		,[DiscountLabor]		= @DiscountLabor
		,[PartCost]				= @PartCost
		,[DiscountPart]		    = @DiscountPart
		,[IsActive]				= @IsActive
	WHERE [ID] = @ID

    SELECT @Rowcount = @@ROWCOUNT
END



GO
/****** Object:  StoredProcedure [dbo].[UpdateSymptom]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[UpdateSymptom]
		@ID						INT	
		,@ModelID				INT	
		,@BrandID				INT
		,@Name					NVARCHAR(200)
		,@Description			NVARCHAR(MAX)
		,@IsActive				BIT	
		,@Rowcount				INT = -1 OUTPUT
AS
BEGIN

	SET NOCOUNT ON;

	UPDATE [dbo].[SymptomTypes]
	SET [ModelID] = @ModelID
		,[BrandID] = @BrandID
		,[Name] = @Name
		,[Description] = @Description
		,[IsActive] = @IsActive
	WHERE [ID] = @ID

    SELECT @Rowcount = @@ROWCOUNT
END



GO
/****** Object:  StoredProcedure [dbo].[UpdateUser]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[UpdateUser]
	@ID						INT
	,@RoleID				INT
	,@Username				NVARCHAR(50)
	,@Password				NVARCHAR(200)
	,@Salt					VARCHAR(64)
	,@Alias					NVARCHAR(200)
	,@CreatedAt				DATETIME
	,@CreatedBy				NVARCHAR(50)
	,@LastUpdatedAt			DATETIME
	,@LastUpdatedBy			NVARCHAR(50)
	,@Rowcount				INT = -1 OUTPUT
AS
BEGIN

	SET NOCOUNT ON;
UPDATE [dbo].[Users]
   SET [RoleID]			= @RoleID
      ,[Username]		= @Username
      ,[Password]		= @Password
      ,[Salt]			= @Salt
      ,[Alias]			= @Alias
      ,[CreatedAt]		= @CreatedAt
      ,[CreatedBy]		= @CreatedBy
      ,[LastUpdatedAt]	= @LastUpdatedAt
      ,[LastUpdatedBy]	= @LastUpdatedBy
	WHERE [ID] = @ID

    SELECT @Rowcount = @@ROWCOUNT
END




GO
/****** Object:  Table [dbo].[Brand]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Brand](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[GenericTypesID] [int] NOT NULL,
	[BrandName] [nvarchar](200) NOT NULL,
	[IsActive] [bit] NULL,
	[CreatedAt] [datetime] NULL,
	[CreatedBy] [nvarchar](50) NULL,
	[LastUpdatedAt] [datetime] NULL,
	[LastUpdatedBy] [nvarchar](50) NULL,
 CONSTRAINT [PK_Brand] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[GenericTypes]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GenericTypes](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Description] [nvarchar](1000) NULL,
	[IsActive] [bit] NULL,
	[CreatedAt] [datetime] NULL,
	[CreatedBy] [nvarchar](50) NULL,
	[LastUpdatedAt] [datetime] NULL,
	[LastUpdatedBy] [nvarchar](50) NULL,
 CONSTRAINT [PK_GenericTypes] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Model]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Model](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[BrandID] [int] NOT NULL,
	[ModelName] [nvarchar](200) NOT NULL,
	[Version] [nvarchar](50) NOT NULL,
	[Manufacturer] [nvarchar](500) NULL,
	[IsActive] [bit] NULL,
	[CreatedAt] [datetime] NULL,
	[CreatedBy] [nvarchar](50) NULL,
	[LastUpdatedAt] [datetime] NULL,
	[LastUpdatedBy] [nvarchar](50) NULL,
 CONSTRAINT [PK_Model] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Orders]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Orders](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[CustomerID] [int] NOT NULL,
	[CreatedAt] [datetime] NOT NULL,
	[CustomerDescription] [nvarchar](max) NULL,
	[ServiceID] [int] NOT NULL,
	[TechnicianID] [int] NOT NULL,
	[AcceptedAt] [datetime] NOT NULL,
	[TechnicianDescription] [nvarchar](max) NULL,
	[DueDate] [datetime] NULL,
	[LastUpdatedAt] [datetime] NULL,
	[LastUpdatedBy] [nvarchar](50) NULL,
	[StatusID] [int] NULL,
	[ExtraFee] [float] NULL,
	[ExtraFeeNote] [nvarchar](2000) NULL,
	[BillingAddress] [nvarchar](max) NULL,
	[ShippingAddress] [nvarchar](max) NULL,
	[IsActive] [bit] NULL,
	[CreatedBy] [nvarchar](50) NULL,
 CONSTRAINT [PK_Orders] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[OrderStatus]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[OrderStatus](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Description] [nvarchar](500) NOT NULL,
 CONSTRAINT [PK_OrderStatus] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Services]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Services](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[GenericTypesID] [int] NOT NULL,
	[SymptomTypeID] [int] NOT NULL,
	[ServiceName] [nvarchar](500) NULL,
	[ServiceDescription] [nvarchar](max) NULL,
	[LaborCost] [float] NULL,
	[DiscountLabor] [float] NULL,
	[PartCost] [float] NULL,
	[DiscountPart] [float] NULL,
	[IsActive] [bit] NULL,
	[CreatedAt] [datetime] NULL,
	[CreatedBy] [nvarchar](50) NULL,
	[LastUpdatedAt] [datetime] NULL,
	[LastUpdatedBy] [nvarchar](50) NULL,
 CONSTRAINT [PK_Services] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[SymptomTypes]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SymptomTypes](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ModelID] [int] NOT NULL,
	[BrandID] [int] NOT NULL,
	[Name] [nvarchar](200) NOT NULL,
	[Description] [nvarchar](max) NOT NULL,
	[IsActive] [bit] NULL,
	[CreatedAt] [datetime] NULL,
	[CreatedBy] [nvarchar](50) NULL,
	[LastUpdatedAt] [datetime] NULL,
	[LastUpdatedBy] [nvarchar](50) NULL,
 CONSTRAINT [PK_SymptomTypes] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[UserRoles]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[UserRoles](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Description] [nvarchar](2000) NULL,
 CONSTRAINT [PK_UserRoles] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Users]    Script Date: 2/23/2014 2:14:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Users](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[RoleID] [int] NOT NULL,
	[Username] [nvarchar](50) NOT NULL,
	[Password] [nvarchar](200) NOT NULL,
	[Salt] [varchar](64) NULL,
	[Alias] [nvarchar](200) NULL,
	[CreatedAt] [datetime] NULL,
	[CreatedBy] [nvarchar](50) NULL,
	[LastUpdatedAt] [datetime] NULL,
	[LastUpdatedBy] [nvarchar](50) NULL,
	[IsActive] [bit] NULL,
 CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
SET IDENTITY_INSERT [dbo].[Brand] ON 

GO
INSERT [dbo].[Brand] ([ID], [GenericTypesID], [BrandName], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (2, 1, N'Apple', 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Brand] ([ID], [GenericTypesID], [BrandName], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (3, 2, N'Samsung', 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Brand] ([ID], [GenericTypesID], [BrandName], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (4, 2, N'LG', 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Brand] ([ID], [GenericTypesID], [BrandName], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (5, 1, N'Lenovo', 1, CAST(0x0000A2DA015BA566 AS DateTime), N'', CAST(0x0000A2DA015BA566 AS DateTime), NULL)
GO
INSERT [dbo].[Brand] ([ID], [GenericTypesID], [BrandName], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (6, 1, N'Skype', 1, CAST(0x0000A2DA015BBF54 AS DateTime), N'', CAST(0x0000A2DA015BBF54 AS DateTime), NULL)
GO
INSERT [dbo].[Brand] ([ID], [GenericTypesID], [BrandName], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (7, 1, N'Test2', 1, CAST(0x0000A2DA015E4E9A AS DateTime), N'', CAST(0x0000A2DA015F2146 AS DateTime), N'')
GO
SET IDENTITY_INSERT [dbo].[Brand] OFF
GO
SET IDENTITY_INSERT [dbo].[GenericTypes] ON 

GO
INSERT [dbo].[GenericTypes] ([ID], [Description], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (1, N'Mobile device type', NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[GenericTypes] ([ID], [Description], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (2, N'Laptop device type', NULL, NULL, NULL, NULL, NULL)
GO
SET IDENTITY_INSERT [dbo].[GenericTypes] OFF
GO
SET IDENTITY_INSERT [dbo].[Model] ON 

GO
INSERT [dbo].[Model] ([ID], [BrandID], [ModelName], [Version], [Manufacturer], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (2, 2, N'iPhone 3G', N'3', N'Apple', 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Model] ([ID], [BrandID], [ModelName], [Version], [Manufacturer], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (3, 2, N'iPhone 4G', N'4', N'Apple', 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Model] ([ID], [BrandID], [ModelName], [Version], [Manufacturer], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (4, 2, N'iPhone 4S', N'4', N'Apple', 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Model] ([ID], [BrandID], [ModelName], [Version], [Manufacturer], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (5, 3, N'Galaxy S5', N'5', N'Samsung', 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Model] ([ID], [BrandID], [ModelName], [Version], [Manufacturer], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (6, 4, N'Optimus', N'4', N'LG', 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Model] ([ID], [BrandID], [ModelName], [Version], [Manufacturer], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (7, 2, N'MacBook Air', N'2', N'Apple', 1, CAST(0x0000A2DB0001A9B5 AS DateTime), N'', NULL, NULL)
GO
INSERT [dbo].[Model] ([ID], [BrandID], [ModelName], [Version], [Manufacturer], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (8, 6, N'Skype 04', N'2014', N'Skype Korea', 1, CAST(0x0000A2DB0001D460 AS DateTime), N'', CAST(0x0000A2DB0005E371 AS DateTime), N'')
GO
SET IDENTITY_INSERT [dbo].[Model] OFF
GO
SET IDENTITY_INSERT [dbo].[Orders] ON 

GO
INSERT [dbo].[Orders] ([ID], [CustomerID], [CreatedAt], [CustomerDescription], [ServiceID], [TechnicianID], [AcceptedAt], [TechnicianDescription], [DueDate], [LastUpdatedAt], [LastUpdatedBy], [StatusID], [ExtraFee], [ExtraFeeNote], [BillingAddress], [ShippingAddress], [IsActive], [CreatedBy]) VALUES (1, 5, CAST(0x0000A13A00000000 AS DateTime), NULL, 1, 3, CAST(0x0000A1C400000000 AS DateTime), NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Orders] ([ID], [CustomerID], [CreatedAt], [CustomerDescription], [ServiceID], [TechnicianID], [AcceptedAt], [TechnicianDescription], [DueDate], [LastUpdatedAt], [LastUpdatedBy], [StatusID], [ExtraFee], [ExtraFeeNote], [BillingAddress], [ShippingAddress], [IsActive], [CreatedBy]) VALUES (2, 6, CAST(0x0000A1F700000000 AS DateTime), NULL, 2, 3, CAST(0x0000A21400000000 AS DateTime), NULL, NULL, NULL, NULL, 2, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Orders] ([ID], [CustomerID], [CreatedAt], [CustomerDescription], [ServiceID], [TechnicianID], [AcceptedAt], [TechnicianDescription], [DueDate], [LastUpdatedAt], [LastUpdatedBy], [StatusID], [ExtraFee], [ExtraFeeNote], [BillingAddress], [ShippingAddress], [IsActive], [CreatedBy]) VALUES (3, 7, CAST(0x0000A13D00000000 AS DateTime), NULL, 3, 11, CAST(0x0000A19600000000 AS DateTime), NULL, NULL, NULL, NULL, 3, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Orders] ([ID], [CustomerID], [CreatedAt], [CustomerDescription], [ServiceID], [TechnicianID], [AcceptedAt], [TechnicianDescription], [DueDate], [LastUpdatedAt], [LastUpdatedBy], [StatusID], [ExtraFee], [ExtraFeeNote], [BillingAddress], [ShippingAddress], [IsActive], [CreatedBy]) VALUES (5, 8, CAST(0x0000A15900000000 AS DateTime), NULL, 4, 4, CAST(0x0000A1B500000000 AS DateTime), NULL, NULL, NULL, NULL, 4, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Orders] ([ID], [CustomerID], [CreatedAt], [CustomerDescription], [ServiceID], [TechnicianID], [AcceptedAt], [TechnicianDescription], [DueDate], [LastUpdatedAt], [LastUpdatedBy], [StatusID], [ExtraFee], [ExtraFeeNote], [BillingAddress], [ShippingAddress], [IsActive], [CreatedBy]) VALUES (6, 9, CAST(0x0000A17900000000 AS DateTime), NULL, 5, 4, CAST(0x0000A1B500000000 AS DateTime), NULL, NULL, NULL, NULL, 5, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Orders] ([ID], [CustomerID], [CreatedAt], [CustomerDescription], [ServiceID], [TechnicianID], [AcceptedAt], [TechnicianDescription], [DueDate], [LastUpdatedAt], [LastUpdatedBy], [StatusID], [ExtraFee], [ExtraFeeNote], [BillingAddress], [ShippingAddress], [IsActive], [CreatedBy]) VALUES (7, 10, CAST(0x0000A13A00000000 AS DateTime), NULL, 6, 11, CAST(0x0000A18200000000 AS DateTime), NULL, NULL, NULL, NULL, 3, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Orders] ([ID], [CustomerID], [CreatedAt], [CustomerDescription], [ServiceID], [TechnicianID], [AcceptedAt], [TechnicianDescription], [DueDate], [LastUpdatedAt], [LastUpdatedBy], [StatusID], [ExtraFee], [ExtraFeeNote], [BillingAddress], [ShippingAddress], [IsActive], [CreatedBy]) VALUES (9, 12, CAST(0x0000A1BF00000000 AS DateTime), NULL, 7, 4, CAST(0x0000A21500000000 AS DateTime), NULL, NULL, NULL, NULL, 4, NULL, NULL, NULL, NULL, NULL, NULL)
GO
SET IDENTITY_INSERT [dbo].[Orders] OFF
GO
SET IDENTITY_INSERT [dbo].[OrderStatus] ON 

GO
INSERT [dbo].[OrderStatus] ([ID], [Description]) VALUES (1, N'Completed')
GO
INSERT [dbo].[OrderStatus] ([ID], [Description]) VALUES (2, N'Waiting components')
GO
INSERT [dbo].[OrderStatus] ([ID], [Description]) VALUES (3, N'Cannot fix')
GO
INSERT [dbo].[OrderStatus] ([ID], [Description]) VALUES (4, N'In waiting list')
GO
INSERT [dbo].[OrderStatus] ([ID], [Description]) VALUES (5, N'Fixing')
GO
SET IDENTITY_INSERT [dbo].[OrderStatus] OFF
GO
SET IDENTITY_INSERT [dbo].[Services] ON 

GO
INSERT [dbo].[Services] ([ID], [GenericTypesID], [SymptomTypeID], [ServiceName], [ServiceDescription], [LaborCost], [DiscountLabor], [PartCost], [DiscountPart], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (1, 1, 1, N'Auto reboot', N'Automatic reboot and loss of all data', 0.2, 0.1, 0.1, 0.3, 0, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Services] ([ID], [GenericTypesID], [SymptomTypeID], [ServiceName], [ServiceDescription], [LaborCost], [DiscountLabor], [PartCost], [DiscountPart], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (2, 2, 2, N'Low resolution', N'Very low resolution picture showing on the screen when a contact calls you', 0.2, 0.1, 0.1, 0.1, 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Services] ([ID], [GenericTypesID], [SymptomTypeID], [ServiceName], [ServiceDescription], [LaborCost], [DiscountLabor], [PartCost], [DiscountPart], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (3, 2, 4, N'Wrong zoom', N'most icons are zoomed in and pixelated', 0.2, 0.15, 0.1, 0.5, 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Services] ([ID], [GenericTypesID], [SymptomTypeID], [ServiceName], [ServiceDescription], [LaborCost], [DiscountLabor], [PartCost], [DiscountPart], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (4, 2, 5, N'Not charge', N'can not charge', 0.1, 0.1, 0.1, 0.1, 0, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Services] ([ID], [GenericTypesID], [SymptomTypeID], [ServiceName], [ServiceDescription], [LaborCost], [DiscountLabor], [PartCost], [DiscountPart], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (5, 2, 6, N'Wireless problem', N'Weak or lost Weak or lost wireless connections', 0.1, 0.1, 0.1, 0.1, 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Services] ([ID], [GenericTypesID], [SymptomTypeID], [ServiceName], [ServiceDescription], [LaborCost], [DiscountLabor], [PartCost], [DiscountPart], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (6, 2, 7, N'Camera problem', N'Rear camera white balance doesn’t work', 0.1, 0.1, 0.1, 0.1, 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Services] ([ID], [GenericTypesID], [SymptomTypeID], [ServiceName], [ServiceDescription], [LaborCost], [DiscountLabor], [PartCost], [DiscountPart], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (7, 1, 3, N'Email problem', N'Email notification sounds laggy/distorted', 0.1, 0.1, 0.1, 0.1, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Services] ([ID], [GenericTypesID], [SymptomTypeID], [ServiceName], [ServiceDescription], [LaborCost], [DiscountLabor], [PartCost], [DiscountPart], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (9, 1, 1, N'Unstable', N'The device works in a fluctuating manner!', 0.1, 0.1, 0.1, 0.6, 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Services] ([ID], [GenericTypesID], [SymptomTypeID], [ServiceName], [ServiceDescription], [LaborCost], [DiscountLabor], [PartCost], [DiscountPart], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (12, 2, 1, N'High temperature', N'sooo hoooot!', 0.9, 1, 0.3, 0.2, 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Services] ([ID], [GenericTypesID], [SymptomTypeID], [ServiceName], [ServiceDescription], [LaborCost], [DiscountLabor], [PartCost], [DiscountPart], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (13, 2, 4, N'Reinstall driver', N'Fix driver', 0.2, 0.15, 0, 0.6, 1, NULL, NULL, NULL, NULL)
GO
SET IDENTITY_INSERT [dbo].[Services] OFF
GO
SET IDENTITY_INSERT [dbo].[SymptomTypes] ON 

GO
INSERT [dbo].[SymptomTypes] ([ID], [ModelID], [BrandID], [Name], [Description], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (1, 3, 2, N'Auto reboot', N'Automatic reboot and loss of all data', 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[SymptomTypes] ([ID], [ModelID], [BrandID], [Name], [Description], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (2, 2, 2, N'low resolution', N'Very low resolution picture showing on the screen when a contact calls you', 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[SymptomTypes] ([ID], [ModelID], [BrandID], [Name], [Description], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (3, 2, 2, N'Email problem', N'Email notification sounds laggy/distorted', 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[SymptomTypes] ([ID], [ModelID], [BrandID], [Name], [Description], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (4, 2, 2, N'Wrong zoom', N'most icons are zoomed in and pixelated', 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[SymptomTypes] ([ID], [ModelID], [BrandID], [Name], [Description], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (5, 2, 2, N'not charge', N'can not charge', 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[SymptomTypes] ([ID], [ModelID], [BrandID], [Name], [Description], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (6, 2, 2, N'wireless problem', N'Weak or lost Weak or lost wireless connections', NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[SymptomTypes] ([ID], [ModelID], [BrandID], [Name], [Description], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (7, 2, 2, N'camera problem', N'Rear camera white balance doesn’t work', 1, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[SymptomTypes] ([ID], [ModelID], [BrandID], [Name], [Description], [IsActive], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy]) VALUES (8, 5, 3, N'Broken display', N'Replace the display part.', 1, NULL, NULL, NULL, NULL)
GO
SET IDENTITY_INSERT [dbo].[SymptomTypes] OFF
GO
SET IDENTITY_INSERT [dbo].[UserRoles] ON 

GO
INSERT [dbo].[UserRoles] ([ID], [Description]) VALUES (1, N'System Admin')
GO
INSERT [dbo].[UserRoles] ([ID], [Description]) VALUES (2, N'Admin')
GO
INSERT [dbo].[UserRoles] ([ID], [Description]) VALUES (3, N'Technician')
GO
INSERT [dbo].[UserRoles] ([ID], [Description]) VALUES (4, N'Customer')
GO
SET IDENTITY_INSERT [dbo].[UserRoles] OFF
GO
SET IDENTITY_INSERT [dbo].[Users] ON 

GO
INSERT [dbo].[Users] ([ID], [RoleID], [Username], [Password], [Salt], [Alias], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy], [IsActive]) VALUES (1, 1, N'sysadmin', N'@123', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Users] ([ID], [RoleID], [Username], [Password], [Salt], [Alias], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy], [IsActive]) VALUES (2, 1, N'dle', N'244', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Users] ([ID], [RoleID], [Username], [Password], [Salt], [Alias], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy], [IsActive]) VALUES (3, 2, N'abc', N'544', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Users] ([ID], [RoleID], [Username], [Password], [Salt], [Alias], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy], [IsActive]) VALUES (4, 2, N'nam', N'5433', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Users] ([ID], [RoleID], [Username], [Password], [Salt], [Alias], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy], [IsActive]) VALUES (5, 3, N'tung', N'fasdf45', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Users] ([ID], [RoleID], [Username], [Password], [Salt], [Alias], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy], [IsActive]) VALUES (6, 3, N'lan', N'fer32', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Users] ([ID], [RoleID], [Username], [Password], [Salt], [Alias], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy], [IsActive]) VALUES (7, 3, N'toan', N'fasd4343', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Users] ([ID], [RoleID], [Username], [Password], [Salt], [Alias], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy], [IsActive]) VALUES (8, 3, N'hung', N'fasdfj54', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Users] ([ID], [RoleID], [Username], [Password], [Salt], [Alias], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy], [IsActive]) VALUES (9, 3, N'ngoc', N'oij4534', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Users] ([ID], [RoleID], [Username], [Password], [Salt], [Alias], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy], [IsActive]) VALUES (10, 3, N'binh', N'4354', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Users] ([ID], [RoleID], [Username], [Password], [Salt], [Alias], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy], [IsActive]) VALUES (11, 2, N'yen', N'4094', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
GO
INSERT [dbo].[Users] ([ID], [RoleID], [Username], [Password], [Salt], [Alias], [CreatedAt], [CreatedBy], [LastUpdatedAt], [LastUpdatedBy], [IsActive]) VALUES (12, 3, N'bao', N'435jlj', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
GO
SET IDENTITY_INSERT [dbo].[Users] OFF
GO
ALTER TABLE [dbo].[Model]  WITH CHECK ADD  CONSTRAINT [FK_Model_Brand] FOREIGN KEY([BrandID])
REFERENCES [dbo].[Brand] ([ID])
GO
ALTER TABLE [dbo].[Model] CHECK CONSTRAINT [FK_Model_Brand]
GO
ALTER TABLE [dbo].[Orders]  WITH CHECK ADD  CONSTRAINT [FK_Orders_OrderStatus] FOREIGN KEY([StatusID])
REFERENCES [dbo].[OrderStatus] ([ID])
GO
ALTER TABLE [dbo].[Orders] CHECK CONSTRAINT [FK_Orders_OrderStatus]
GO
ALTER TABLE [dbo].[Orders]  WITH CHECK ADD  CONSTRAINT [FK_Orders_Services] FOREIGN KEY([ServiceID])
REFERENCES [dbo].[Services] ([ID])
GO
ALTER TABLE [dbo].[Orders] CHECK CONSTRAINT [FK_Orders_Services]
GO
ALTER TABLE [dbo].[Orders]  WITH CHECK ADD  CONSTRAINT [FK_Orders_Users] FOREIGN KEY([CustomerID])
REFERENCES [dbo].[Users] ([ID])
GO
ALTER TABLE [dbo].[Orders] CHECK CONSTRAINT [FK_Orders_Users]
GO
ALTER TABLE [dbo].[Orders]  WITH CHECK ADD  CONSTRAINT [FK_Orders_Users1] FOREIGN KEY([TechnicianID])
REFERENCES [dbo].[Users] ([ID])
GO
ALTER TABLE [dbo].[Orders] CHECK CONSTRAINT [FK_Orders_Users1]
GO
ALTER TABLE [dbo].[Services]  WITH CHECK ADD  CONSTRAINT [FK_Services_GenericTypes] FOREIGN KEY([GenericTypesID])
REFERENCES [dbo].[GenericTypes] ([ID])
GO
ALTER TABLE [dbo].[Services] CHECK CONSTRAINT [FK_Services_GenericTypes]
GO
ALTER TABLE [dbo].[Services]  WITH CHECK ADD  CONSTRAINT [FK_Services_SymptomTypes] FOREIGN KEY([SymptomTypeID])
REFERENCES [dbo].[SymptomTypes] ([ID])
GO
ALTER TABLE [dbo].[Services] CHECK CONSTRAINT [FK_Services_SymptomTypes]
GO
ALTER TABLE [dbo].[SymptomTypes]  WITH CHECK ADD  CONSTRAINT [FK_SymptomTypes_Model] FOREIGN KEY([ModelID])
REFERENCES [dbo].[Model] ([ID])
GO
ALTER TABLE [dbo].[SymptomTypes] CHECK CONSTRAINT [FK_SymptomTypes_Model]
GO
ALTER TABLE [dbo].[Users]  WITH CHECK ADD  CONSTRAINT [FK_Users_UserRoles] FOREIGN KEY([RoleID])
REFERENCES [dbo].[UserRoles] ([ID])
GO
ALTER TABLE [dbo].[Users] CHECK CONSTRAINT [FK_Users_UserRoles]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Type of devices: Laptop (1) or Mobile (2)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Services', @level2type=N'COLUMN',@level2name=N'GenericTypesID'
GO
USE [master]
GO
ALTER DATABASE [xRepair] SET  READ_WRITE 
GO
